cmake_minimum_required(VERSION 3.5)

project("SimDriverBoard")

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Boost REQUIRED COMPONENTS system thread filesystem)

message(STATUS "CMAKE_CURRENT_LIST_DIR = ${CMAKE_CURRENT_LIST_DIR}")        # 显示当前的项目的目录

message(STATUS "start build ................................") 

set(pro_name "SimDriverBoard")                                              # 最终可执行程序的名字
set(pro_name_static "SimDriverBoard_static")                                # 全部源文件先编译成静态库，方便单元测试


file(GLOB_RECURSE src_cpp_files ${CMAKE_CURRENT_LIST_DIR}/*.cpp 
                                ${CMAKE_CURRENT_LIST_DIR}/*.c)
list(REMOVE_ITEM src_cpp_files ${CMAKE_CURRENT_LIST_DIR}/SimDriverBoard_app.cpp)    # 去掉main.cpp


# 编译静态库
add_library(${pro_name_static} STATIC)

message(STATUS "src_cpp_files = ${src_cpp_files}")
target_sources(${pro_name_static} PRIVATE ${src_cpp_files})
message(STATUS "zzz:${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(${pro_name_static} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} 
                                                     ${Boost_INCLUDE_DIRS})

target_link_libraries(${pro_name_static} PRIVATE ${Boost_LIBRARIES})

# 通过静态库编译可执行程序
add_executable(${pro_name})
target_sources(${pro_name} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/SimDriverBoard_app.cpp)
target_link_libraries(${pro_name} ${pro_name_static})
